//1.递归读取文件 --- 输出文件路径
let fs = require("fs");
let path = require("path");

//2.递归读文件
function readdir(p) {

    //读取当前目录下的文件
    let ps = path.join(__dirname, p); //E
    let files = fs.readdirSync(ps);

    //循环当前目录下的文件
    files.forEach(file => { //[a.txt,b.txt,c]
        //如果是文件就直接打印，否则还得再读文件夹
        let msg = fs.statSync(path.join(ps,file));//fs.statSync("demo/a.txt")
        if(msg.isFile()){
            console.log(path.join(ps,file));
        }else{
            //demo/cc
            readdir(path.join(p,file));
        }
    })
}
readdir("demo");